package likou;

/**
 * @author: Tangxz
 * @email: 1171702529@qq.com
 * @cate: 2021/12/05 09:43
 */
public class _372 {
    public static void main(String[] args) {
        _372 one = new _372();
        System.out.println(one.superPow(2147483647,new int[]{2,0,0}));
    }
    int p = 1337;
    int left = 0;
    public int superPow(int a, int[] b) {
        int len = b.length;
        if(left==len) return 1;
        int now = a%p;
        int nowa = now;
        for(int i=left;i<len-1;i++){
            if(b[i]%2==1){
                b[i+1]+=10;
            }
            b[i]/=2;
        }
        if(b[left]==0) left++;
        int qq = b[len-1]%2;
        b[len-1]/=2;
        int res = superPow(nowa*nowa,b);
        if(qq==1){
            res*=nowa;
        }
        return res%p;
    }
}
